package com.dyl.mymodule.app;

import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

/**
 * Created by tukela on 2016/3/14.
 */
public class MyFragment extends Fragment {
    private TextView textView;
    private ListView listView;
    private Context context;
    private String[] zifuzu;

    public static MyFragment newInstance() {

        Bundle args = new Bundle();

        MyFragment fragment = new MyFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context=context;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Resources res =getResources();
        zifuzu=res.getStringArray(R.array.zifuzu);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

       View view= inflater.inflate(R.layout.fragment_my,null);
        textView= (TextView) view.findViewById(R.id.section_label);
        listView=(ListView) view.findViewById(R.id.listview);
        listView.setAdapter(new ArrayAdapter<String>(context,android.R.layout.simple_list_item_1,zifuzu));
        return view;
    }

    public void setText(String str){
        textView.setText(str);
        textView.setTextColor(getResources().getColor(R.color.orange_border));
    }


}
